package view;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Insets;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.Border;

import controller.Controller;
import controller.ControllerLighter;

import view.items.PanelCallRequest;
import view.items.PanelTitre;

import model.Call;
import model.EnumCallStatus;
import model.Model;

public class ViewCallRequest extends ViewAbstract {

	private Model model;
	private Controller controller;
	private ControllerLighter controllerLighter;
	public ViewCallRequest(Controller controller,ControllerLighter controllerLighter, int x, int y, int width, int height) {
		this.model=controller.getModel();
		this.controller = controller;
		this.controllerLighter=controllerLighter;
		this.setBackground(Color.LIGHT_GRAY);
		this.setBounds(x,y,width,height);
		this.refresh();
		this.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 1));
		//this.setBorder(new Border)
	}
	
	
	
	public void refresh() {
		//System.out.println("refreshViewCallRequest");
		this.removeAll();
		//Partie statique

PanelTitre titre = new PanelTitre("Call request");
this.add(titre);
		//Partie dynamique
		List<Call> requestCall = this.model.getCall(EnumCallStatus.REQUEST_RECEIVE);
		if(requestCall.size() !=0){
		for (Call call : requestCall) {
			PanelCallRequest panelCallRequestReceive = new PanelCallRequest(call,controller, controllerLighter);
			this.add(panelCallRequestReceive);
		}
		}
		else{
			JLabel label;
			label = new JLabel("No request call");
			this.add(label);
		}
		this.repaint();
		this.revalidate();
	}
}
